Skip to content

Add conformance test for nested Optional behavior#2240

Closed
BHUVANSH855 wants to merge 1 commit intopython:mainfrom
BHUVANSH855:optional-nested-test
Closed

Add conformance test for nested Optional behavior#2240
BHUVANSH855 wants to merge 1 commit intopython:mainfrom
BHUVANSH855:optional-nested-test

Conversation

@BHUVANSH855
Copy link
Copy Markdown

This PR adds a conformance test for nested Optional types.

Specifically, it verifies that Optional[Optional[T]] behaves as Optional[T],
and ensures that such values are not treated as non-optional types without proper handling.

The test includes:

  • Validation of type collapsing behavior for nested Optional types
  • A negative case where Optional[Optional[int]] is incorrectly used as int

This helps improve coverage of edge cases related to Optional and None handling
in the typing specification.

@python-cla-bot
Copy link
Copy Markdown

python-cla-bot bot commented Apr 6, 2026

All commit authors signed the Contributor License Agreement.

CLA signed

@srittau srittau added the topic: conformance tests Issues with the conformance test suite label Apr 7, 2026
@JelleZijlstra
Copy link
Copy Markdown
Member

Why does this need a new conformance test? The behavior here is obvious and flows from general rules.

@BHUVANSH855
Copy link
Copy Markdown
Author

Why does this need a new conformance test? The behavior here is obvious and flows from general rules.

Thanks for the feedback!

I understand that this behavior is already covered by general rules, so this test may be redundant.

Closing this PR and will look for a more suitable case to contribute.

@BHUVANSH855 BHUVANSH855 closed this Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: conformance tests Issues with the conformance test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants